<?php

/**
 * Created by PhpStorm.
 * User: songs
 * Date: 2019/10/15
 * Time: 12:51
 */

namespace App\Http\Controllers\h5;

use App\Http\Controllers\BaseController;
use App\admin\Service\OA;
use App\Jobs\Fun;
use App\Models\TokenUrlModel;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cookie;

class HomeController extends BaseController {

    public function myset() {
        $user = OA::$user->getModel();
        if (!$user) {
            return  Fun::goLogin();
        } 
        return view('h5.home.myset');
    }

    public function order() {
   //      exit('sssssss');
        $user = OA::$user->getModel();
        if (!$user) {
            return  Fun::goLogin();
        } 
        return view('h5.home.order');
    }
    
  /**
     * 订单详细记录
    */
    public function message(){
         $user = OA::$user->getModel();
        if (!$user) {
            return  Fun::goLogin();
        } 
         return view('h5.home.message');
    }


    public function ToToken(Request $request){


        $md5=$request->get('md5','');
      //  var_dump($md5);
        $first=TokenUrlModel::where([
            'md5'=>$md5
        ])
        //    ->where('time',">",time()-60)
            ->select(['url','token','id'])->first();
        if(!$first){
            Fun::showmsg('系统错误');
        }
        $url=$first->url;
        $token=$first->token;
      //  var_dump($url,$token);exit;
         $first->delete();
       Cookie::queue('token', $token,60*60);

        return view('h5.home.to_token',['url'=>$url]);//->cookie('token',$token, 60*24*7);
      /*  var_dump($url,$token);
        var_dump();
        exit;*/
    }


}
